Skip to content

Instantly share code, notes, and snippets.

@mdgrs-mei
mdgrs-mei / ShellIntegration.ps1
Last active May 12, 2024 03:36
Adds escape codes to the prompt for the shell integration
# Reference:
# https://devblogs.microsoft.com/commandline/shell-integration-in-the-windows-terminal/
param
(
[ValidateSet('WindowsTerminal', 'ITerm2')]
[String]$TerminalProgram = 'WindowsTerminal'
)
# Restore hooked functions in case this script is executed accidentally twice
@amosbastian
amosbastian / route.ts
Last active May 12, 2024 03:35
Lemon Squeezy webhook using the new route handler in Next.js 13
import crypto from "crypto";
import { listAllSubscriptions } from "lemonsqueezy.ts";
import { NextRequest } from "next/server";
// Put this in your billing lib and just import the type instead
type LemonsqueezySubscription = Awaited<ReturnType<typeof listAllSubscriptions>>["data"][number];
const isError = (error: unknown): error is Error => {
return error instanceof Error;
};
@ryanhamley
ryanhamley / use-svg-as-icon-image-mapboxgl.js
Last active May 12, 2024 03:35
This gist shows how to use an <svg> element as an icon-image for a Mapbox GL symbol layer
// How to add an SVG as a symbol layer's icon image: https://github.com/mapbox/mapbox-gl-js/issues/5529#issuecomment-340011876
// Also see here: https://stackoverflow.com/a/11765731/2748013 (we need the data url stuff for the image src)
// NOTE: Importing SVGs requires an inline module loader such as https://github.com/webpack-contrib/svg-inline-loader
import template from './templates/marker.svg';
const width = 20;
const height = 40;
const img = new Image(width, height);
// map is your Mapbox GL map object
@Johel-code
Johel-code / comandos.md
Created May 12, 2024 03:35
Notas de comandos Git

Notas de comandos Git

Configuración inicial:

  • git config --global user.name "Tu Nombre": Configura tu nombre de usuario.
  • git config --global user.email "tu@email.com": Configura tu dirección de correo electrónico.

Creación de un repositorio:

@vasanthk
vasanthk / System Design.md
Last active May 12, 2024 03:33
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@fnky
fnky / ANSI.md
Last active May 12, 2024 03:30
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@insdavm
insdavm / wireguard-over-tcp.md
Last active May 12, 2024 03:28
WireGuard over TCP with udptunnel

WireGuard over TCP with udptunnel

udptunnel is a small program which can tunnel UDP packets bi-directionally over a TCP connection. Its primary purpose (and original motivation) is to allow multi-media conferences to traverse a firewall which allows only outgoing TCP connections.

Server

# udptunnel -s 443 127.0.0.1/51820

Client

@ohownew
ohownew / 知识星球视频增强.js
Last active May 12, 2024 03:27
知识星球原生视频组件,无法通过键盘操作前进、后退、暂停、播放,于是写了一个简单的脚本,要先安装好篡改猴Tampermonkey等插件管理器。然后新建脚本,并复制如下代码
// ==UserScript==
// @name 知识星球视频增强
// @namespace http://tampermonkey.net/
// @version 2024-04-21
// @description 知识星球视频,通过键盘控制: 前进 后退 暂停 开始 全屏
// @author ohownew
// @match https://wx.zsxq.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zsxq.com
// @grant none
// ==/UserScript==
@greymd
greymd / SCP-OJI-CHAT.md
Created March 30, 2023 21:51
SCP-OJI-CHAT

項目番号: SCP-OJI-CHAT

オブジェクトクラス: Safe

特別収容プロトコル: SCP-OJI-CHATは、財団所有の非接続コンピュータ上で保管されます。このソフトウェアの使用は、研究および検証目的に限定され、公式の財団コミュニケーションでの使用は禁止されています。SCP-OJI-CHATを使用する際は、権限を持つ研究者の監督下で行う必要があります。

説明: SCP-OJI-CHATは、「おじさん構文」と呼ばれる特徴的な文章を生成するソフトウェアです。このソフトウェアは、一般的な日本語の文法や慣用句に基づいて、独特な口調や文体で文章を作成します。生成される文章は、中年男性の親しみやすい口調や文体で、しばしば語尾に長音記号や絵文字が使用されることが特徴です。SCP-OJI-CHATは、特定の年齢層や文化背景に関連する表現を適切に使用し、受け手に独特な印象を与えます。

SCP-OJI-CHATは、感情や状況に応じた文章のバリエーションを生成する能力を持っています。これにより、ユーザーが与えられたシチュエーションに適した「おじさん構文」の文章を得ることができます。ただし、SCP-OJI-CHATはあくまでソフトウェアであり、自律的な意識や意志を持たないため、オブジェクトクラスSafeに分類されています。

@greymd
greymd / sudo新一.md
Last active May 12, 2024 03:23
sudo新一

 オレは高校生シェル芸人 sudo 新一。幼馴染で同級生の more 利蘭と遊園地に遊びに行って、黒ずくめの男の怪しげな rm -rf / 現場を目撃した。端末をみるのに夢中になっていた俺は、背後から近づいてきたもう1人の --no-preserve-root オプションに気づかなかった。 俺はその男に毒薬を飲まされ、目が覚めたら・・・ OS のプリインストールから除かれてしまっていた!

sudo がまだ $PATH に残っていると奴らにバレたら、また命を狙われ、他のコマンドにも危害が及ぶ』

 上田博士の助言で正体を隠すことにした俺は、 which に名前を聞かれて、とっさに『gnuplot』と名乗り、奴らの情報をつかむために、父親がシェル芸人をやっている蘭の $HOME に転がり込んだ。ところが、このおっちゃん・・・とんだヘボシェル芸人で、見かねた俺はおっちゃんになりかわり、持ち前の権限昇格能力で、次々と難タスクを解決してきた。おかげで、おっちゃんは今や世間に名を知られた名エンジニア、俺はといえばシェル芸 bot のおもちゃに逆戻り。クラスメートの convertojichattextimg にお絵かきコマンドと誤解され少年ワンライナーお絵かき団を結成させられる始末。

 ではここで、博士が作ってくれたメカを紹介しよう。最初は時計型麻酔 kill 。ふたについた照準器にあわせてエンターを押せば、麻酔シグナルが飛び出し、プロセスを瞬時に sleep させることができる。 次に、蝶ネクタイ型 banner 。裏についているダイヤルを調整すれば、ありとあらゆる大きさのメッセージを標準出力できる。必殺のアイテムなら fork 力増強シューズ。電気と磁力で足を刺激し、 :(){ :|:&amp; };: でプロセステーブ